import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '物料名称',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '物料编码',
    align:"center",
    dataIndex: 'code'
   },
   {
    title: '规格',
    align:"center",
    dataIndex: 'materialspec'
   },
   {
    title: '型号',
    align:"center",
    dataIndex: 'materialtype'
   },
   {
    title: '条形码',
    align:"center",
    dataIndex: 'materialbarcode'
   },
   {
    title: '物料分类',
    align:"center",
    dataIndex: 'pkMarbasclass'
   },
   {
    title: '启用状态',
    align:"center",
    dataIndex: 'enablestate_dictText'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "规格",
      field: 'materialspec',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "型号",
      field: 'materialtype',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "条形码",
      field: 'materialbarcode',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "物料分类",
      field: 'pkMarbasclass',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
        const {setFieldsValue} = formActionType;
        return{
            setFieldsValue:setFieldsValue,
            code:"bd_marbasclass",
            fieldConfig: [
                { source: 'name', target: 'pkMarbasclass' },
                { source: 'id', target: 'marbasclassId' },
            ],
            multi:true
        }
    },

      //colProps: {span: 6},
 	},
	{
      label: "启用状态",
      field: 'enablestate',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"enablestate"
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '物料名称',
    field: 'name',
    component: 'Input',
  },
  {
    label: '物料编码',
    field: 'code',
    component: 'Input',
  },
  {
    label: '规格',
    field: 'materialspec',
    component: 'Input',
  },
  {
    label: '型号',
    field: 'materialtype',
    component: 'Input',
  },
  {
    label: '条形码',
    field: 'materialbarcode',
    component: 'Input',
  },
  {
    label: '物料分类ID',
    field: 'marbasclassId',
    component: 'Input',
    show: false
  },
  {
    label: '物料分类',
    field: 'pkMarbasclass',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
        const {setFieldsValue} = formActionType;
        return{
            setFieldsValue:setFieldsValue,
            code:"bd_marbasclass",
            fieldConfig: [
                { source: 'name', target: 'pkMarbasclass' },
                { source: 'id', target: 'marbasclassId' },
            ],
            multi:true
        }
    },

  },
  {
    label: '启用状态',
    field: 'enablestate',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"enablestate"
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  name: {title: '物料名称',order: 0,view: 'text', type: 'string',},
  code: {title: '物料编码',order: 1,view: 'text', type: 'string',},
  materialspec: {title: '规格',order: 2,view: 'text', type: 'string',},
  materialtype: {title: '型号',order: 3,view: 'text', type: 'string',},
  materialbarcode: {title: '条形码',order: 4,view: 'text', type: 'string',},
  pkMarbasclass: {title: '物料分类',order: 5,view: 'popup', type: 'string',code: 'bd_marbasclass', orgFields: 'name', destFields: 'pkMarbasclass', popupMulti: false,},
  enablestate: {title: '启用状态',order: 6,view: 'list', type: 'string',dictCode: 'enablestate',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
